package com.isunland.managesystem.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BasePagerActivity;

//3.activity实现接口。用activity做跳转。
public class MessagePagerActivity extends BasePagerActivity
    implements MessageSendFragment.Callbacks {

  public static final String EXTRA_REPLY = "com.isunland.managesystem.ui.EXTRA_REPLY";
  public static final String VALUE_REPLY = "com.isunland.managesystem.ui.VALUE_REPLY";
  private MessageSendFragment mSendMassageFragment;
  private MessageSendListFragment mSuccessMassageFragment;
  private MessageReceiveListFragment mReceiveMassageFragment;

  private int[] mTitleId = {
      R.string.receivemessage, R.string.successmessage, R.string.sendmessage
  };

  @Override protected Fragment createFragmentOne() {
    mReceiveMassageFragment = new MessageReceiveListFragment();
    return mReceiveMassageFragment;
  }

  @Override protected Fragment createFragmentTwo() {

    mSuccessMassageFragment = new MessageSendListFragment();
    return mSuccessMassageFragment;
  }

  @Override public Fragment createFragmentThree() {
    mSendMassageFragment = new MessageSendFragment();
    return mSendMassageFragment;
  }

  @Override protected int[] createTitle() {
    return mTitleId;
  }

  //4.接口中方法的具体实现，实际是
  @Override public void onRefresh() {
    setNavigateTo(1);
    mSuccessMassageFragment.refresh();
  }

  @Override protected void onCreate(Bundle arg0) {
    // Auto-generated method stub
    super.onCreate(arg0);
    String reply = getIntent().getStringExtra(EXTRA_REPLY);
    if (reply != null && reply.equals(VALUE_REPLY)) {
      setNavigateTo(1);
    }
  }

  @Override protected void setFixedTitle(boolean isFixedTitle, String fixedTitle) {
    // Auto-generated method stub
    super.setFixedTitle(true, getString(R.string.my_message));
  }
}
